package com.ymxk.livedata;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.timestar.event.EventData;
import com.timestar.event.IEventType;
import com.timestar.event.LiveDataBus;

public class LiveData2Activity extends AppCompatActivity {

    public static void jumpTo(Context context) {
        Intent intent = new Intent(context, LiveData2Activity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_live_data2);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        findViewById(R.id.tvChange).setOnClickListener(view -> {
            //更新并进行变化、LiveDataBus//
            //EventBus.getDefault().register(this);
            LiveDataBus.getDefault().post(new EventData("数据变了、、、", IEventType.EVENT_MAIN));
        });
    }


}